package com.kokomi.config;
import com.kokomi.handler.myInterceptor.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

//@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    @Autowired
    private LoginInterceptor loginInterceptor;

    public void addInterceptors(InterceptorRegistry registry) {

        //将自己的拦截器注册到容器中
        InterceptorRegistration registration = registry.addInterceptor(loginInterceptor);

        //使用注册器来配置拦截内容
        registration.addPathPatterns("/**");

        //配置不拦截的内容
        registration.excludePathPatterns(
                "/**/login",
                "/",
                "/**/*.html",
                "/**/*.js",
                "/**/*.css",
                "/api/upload/avatar",
                "/user/enroll"
        );
    }
}
